package com.learn.demo.lambda.method;

import com.learn.demo.lambda.Person;

import java.util.Comparator;
import java.util.function.BiPredicate;
import java.util.function.Supplier;

/**
 * 方法引用
 * 对象::实例方法名
 * 类::实例方法名
 * 类::静态方法名
 *
 * @author banjiawei
 * @date 2021/06/22
 */
public class MethodRef {
    public static void main(String[] args) {
        //对象::实例方法名
        Person person = new Person();
        person.setName("测试——对象::实例方法名");
        Supplier<String> supplier = person::getName;
        String s = supplier.get();
        System.out.println(s);
        //类::实例方法名
        BiPredicate<String, String> biPredicate = String::equalsIgnoreCase;
        boolean test = biPredicate.test("abc", "Abc");
        System.out.println(test);
        //类::静态方法名
        Comparator<Integer> comparator = Integer::compare;
        int compare = comparator.compare(1, 2);
        System.out.println(compare);
    }
}
